package com.ldp.designpatterns.study.decorator;

import com.ldp.designpatterns.study.decorator.concreteComponent.SimpleCoffee;
import com.ldp.designpatterns.study.decorator.component.Coffee;
import com.ldp.designpatterns.study.decorator.concreteDecorator.MilkDecorator;
import com.ldp.designpatterns.study.decorator.concreteDecorator.SugarDecorator;

/**
 * @ClassName DecoratorTest
 * @Description 装饰者模式：
 * TODO:  在这个示例中，Coffee 接口定义了基本的咖啡功能。SimpleCoffee 类实现了基本的咖啡。
 * TODO: CoffeeDecorator 是装饰器的抽象类，它维护一个被装饰的咖啡对象。
 * TODO:  MilkDecorator 和 SugarDecorator 分别实现了具体的装饰器，通过在原始咖啡上添加新的功能
 * @Author lindipei
 * @Date 2023/10/17 14:42
 */
public class DecoratorTest {
    public static void main(String[] args) {
        Coffee simpleCoffee = new SimpleCoffee();
        System.out.println("Cost: $" + simpleCoffee.cost() + ", Description: " + simpleCoffee.description());

        Coffee milkCoffee = new MilkDecorator(simpleCoffee);
        System.out.println("Cost: $" + milkCoffee.cost() + ", Description: " + milkCoffee.description());

        Coffee sugarMilkCoffee = new SugarDecorator(milkCoffee);
        System.out.println("Cost: $" + sugarMilkCoffee.cost() + ", Description: " + sugarMilkCoffee.description());
    }
}
